<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script>
        let userMsg = localStorage.getItem("userMsg");
        userMsg = userMsg ? JSON.parse(userMsg) : {};
        // 判断状态，决定是否登录
        if(userMsg.code !== 1){
            location.assign("./login.html");
        }
    </script>
</head>
<body>
    这是个人中心<br>
    <a href="./index.html">回到首页</a>
    <p></p>
</body>
<script type="module">
    import $ from "./modules/select.js";
    import ajax from "./modules/ajax.js";

    ajax({
        url:"http://localhost:3000/getuser",
        data:{
            token: userMsg.token
        }
    }).then(res=>{
        res = JSON.parse(res).data;
        // 将用户信息渲染到对应的内容即可
        console.log(res)
        $("p").innerText = res.username
    })

    
</script>
</html>